#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QButtonGroup>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //分组
//    QButtonGroup group1;
    QButtonGroup* group1 = new QButtonGroup(this);
    group1->addButton(ui->radioButton_1);
    group1->addButton(ui->radioButton_2);
    group1->addButton(ui->radioButton_3);

//    QButtonGroup group2;
    QButtonGroup* group2 = new QButtonGroup(this);
    group2->addButton(ui->radioButton_4);
    group2->addButton(ui->radioButton_5);
    group2->addButton(ui->radioButton_6);

//    QButtonGroup group3;
    QButtonGroup* group3 = new QButtonGroup(this);
    group3->addButton(ui->radioButton_7);
    group3->addButton(ui->radioButton_8);
    group3->addButton(ui->radioButton_9);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    // 输出选择主食、菜品、饮品
    QString str = "你的选择是 : ";
    if(ui->radioButton_1->isChecked())
        str += ui->radioButton_1->text() + " ";
    if(ui->radioButton_2->isChecked())
        str += ui->radioButton_2->text() + " ";
    if(ui->radioButton_3->isChecked())
        str += ui->radioButton_3->text() + " ";

    if(ui->radioButton_4->isChecked())
        str += ui->radioButton_4->text() + " ";
    if(ui->radioButton_5->isChecked())
        str += ui->radioButton_5->text() + " ";
    if(ui->radioButton_6->isChecked())
        str += ui->radioButton_6->text() + " ";

    if(ui->radioButton_7->isChecked())
        str += ui->radioButton_7->text() + " ";
    if(ui->radioButton_8->isChecked())
        str += ui->radioButton_8->text() + " ";
    if(ui->radioButton_9->isChecked())
        str += ui->radioButton_9->text() + " ";
    ui->label->setText(str);
    qDebug() << str;

}
